import Sprite = Laya.Sprite;
import Image = Laya.Image

export default class Line extends Laya.Sprite {
    public line;
    public spot
    static change:boolean = true


    constructor(){
        super()
        Laya.stage.once("clearChange",this,this.clearChange)
  
    }
    drawLine(x0:number,y0:number,x:number,y:number){//线
        this.line = new Sprite()
        Laya.stage.addChild(this.line)
        this.line.graphics.drawLine(x0,y0,x,y,"#ffffff",10);
        var filter: Laya.GlowFilter = new Laya.GlowFilter("#3544a5", 15, 0, 0);
        this.line.filters = [filter,filter]
        return this.line
    }

    drawSpot(x:number,y:number){//点
        this.spot = new Image()
        this.spot.skin = "images/spot.png"
        Laya.stage.addChild(this.spot)
        this.spot.x = x
        this.spot.y = y
        this.spot.width = 100
        this.spot.height = 100
        this.spot.pivotX = 50
        this.spot.pivotY = 50
        Laya.stage.timerLoop(100,this,this.changImg)
        return this.spot
    }

    changImg(){
        if(this.change){
            this.spot.skin = "images/spotC.png"
            this.spot.scaleX = 1.2
            this.spot.scaleY = 1.2
            console.log("change")
            this.change = false
        }else{
            this.spot.skin = "images/spot.png"
            this.spot.scaleX = 1.2
            this.spot.scaleY = 1.2
            this.change = true
            console.log("Nochange")
        }
    }

    clearChange(){
        Laya.timer.clear(this,this.changImg)
    }
}